#!/bin/bash
for index in $(curl  -s 'http://192.168.99.114:9200/_cat/shards' | grep UNASSIGNED | awk '{print $1}' | sort | uniq); do
    for shard in $(curl  -s 'http://192.168.99.114:9200/_cat/shards' | grep UNASSIGNED | grep $index | awk '{print $2}' | sort | uniq); do
        echo  $index $shard
          #curl -XDELETE  http://192.168.99.114:9200/$index
          curl -XPOST 'localhost:9200/_cluster/reroute' -d '{
                "commands": [{
                    "allocate": {
                        "index": $index,
                        "shard": $shard,
                        "node": "pb9otSO4QguNOA5Its19GQ",
                        "allow_primary": 1
                    }
                }]
            }'
        sleep 1
    done
done

curl -XPUT "http://192.168.99.114:9200/_settings" -d' {  "number_of_replicas" : 0 } '

curl -XDELETE 'http://192.168.99.114:9200/tcjk_2018.02*'